import localHttp from "@/src/index";
window.onload = function(){
  let list = [],app:HTMLElement = document.querySelector("#app") as HTMLElement;
  let option = {pageNo:1,pageSize:6,total:5};
  let getList = function(){
    localHttp({
      url:'/projectList',
      data:option
    }).then((res:any)=>{
      let htmlstr:string = '';

      option.total = res.data.total;
      list = res.data.list;
      list.forEach((item:any)=>{
        htmlstr+= `<p>${item.prdName}</p>`;
      });
      app.innerHTML = htmlstr; 
    })
  }
  document.querySelector("#previous")?.addEventListener('click',function(){
    option.pageNo--;
    option.pageNo = option.pageNo || 1;
    getList();
  })
  document.querySelector("#next")?.addEventListener('click',function(){
    if(option.pageNo*option.pageSize >= option.total)return;
    option.pageNo++;
    getList();
  })
  getList();
}